<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('发票预制')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
    <link rel="stylesheet" th:href="@{static/js/editable/css/bootstrap-editable.css}">
</head>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
		<div class="col-sm-12 search-condition">
			<form id="billsForm" th:action="@{/scmBills/list?statusCh=gt0&invoiceStatusCh=les1}" class="form-inline">
				<div class="select-list">
				<ul>
					<li class="col-sm-3">
					<label style="width: 120px">采购凭证号：</label>
					<input type="text" name="poNo" />
					</li>
					<li class="col-sm-3">
					<label style="width: 120px">订单类型：</label>
					    <select name="poType" sysDict="CGDDLX" emptyFirst="true"></select>
					</li>
					<li class="col-sm-3">
					<label style="width: 120px">供应商SAP编码：</label>
					    <input type="text" name="sapCode"/>
					</li>
					<li class="col-sm-3">
					<label style="width: 120px">供应商SRM编码：</label>
					    <input type="text" name="srmCode"/>
					</li>
					<li class="col-sm-3">
					<label style="width: 120px">采购组：</label>
					    <select name="purchGroup" sysDict="CGZ" emptyFirst="true"></select>
					</li>
					<li class="col-sm-3">
					<label style="width: 120px">物料编码：</label>
					    <input type="text" name="materialCode" />
					</li>
					<li class="col-sm-3">
					<button id="billsSearchBtn" type="button" class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索</button>
					<button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置</button>
					<button id="billsAdvancedSearch" type="button" class="btn btn-primary btn-rounded btn-sm" style="display: none"><i class="fa fa-caret-down"></i>&nbsp;高级搜索</button>
					</li>
				</ul>
				</div>
			</form>
		</div>
		
		<div class="col-sm-12 select-info order-table">
		    <div class="btn-group hidden-xs toolbar" id="billsToolBar" role="group">
		    <a class="btn btn-outline btn-success btn-rounded" onclick="genInvoices()">
				<i class="fa fa-edit"></i> 发票预制
			</a>
			</div>
			<table id="bills" data-mobile-responsive="true"></table>
		</div>
		
    </div>
</div>

<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<script type="text/javascript">
    //面向对象
    var searcherBS = Searcher.createBS('#bills',
        [
		{checkbox: true},
		{title: '对账单号', field:'billNo'},
		{title: '采购凭证号', field:'poNo'},
		{title: '订单行项目号', field:'itemNo'},
		{title: '物料编码', field:'materialCode'},
		{title: '物料描述', field:'materialDesc'},
		{title: '工厂', field:'factory'},
		{title: '库存地点', field:'storageLocation'},
		{title: '物料组', field:'materialGroup'},
		{title: '需求者姓名', field:'requester'},
		{title: '采购订单数量', field:'poCount'},
		{title: '采购订单的计量单位', field:'poUnit'},
		{title: '含税单价', field:'poPrice'},
		{title: '价格单位', field:'priceUnit'},
		{title: '税码', field:'taxCode'},
		{title: '订单总价值', field:'totalPrice'},
		{title: '收货日期', field:'receiptDate'},
		{title: '成本中心', field:'costCenter'},
		{title: '订单类型', field:'poType'},
		{title: '公司代码', field:'companyCode'},
		{title: '采购组', field:'purchGroup'},
		{title: '采购组织', field:'purchOrg'},
		{title: '付款条件代码', field:'payCondition'},
		{title: '货币码', field:'currencyCode'},
		{title: '供应商', field:'vendorName'},
		{title: '供应商建议交期', field:'deliveryDate'}
        ]
    );
    
    /**
     * 查询数据
     */
    function refresh() {
    	searcherBS.refresh();
    }
    
    $(function () {
    	initDictDataSel();//初始化所有字典数据
    });
    
    //生成预制发票
    function genInvoices() {
        var rowDatas = searcherBS.getSelectedRows("pkId");
        if (rowDatas.length != 1) {
            Dialog.errorMsg("请选择一行进行操作！");
            return;
        }
        
       Dialog.openUrl("预制发票", ctxPath + '/invoice/toGenInvoice?billId='+rowDatas[0],{area : ['1300px','560px'],
            maxmin: true,
            end: function() {}
        });
    }
    
</script>
</body>
</html>